package com.pactera.madp.cp.api.dto.wm;

import com.pactera.madp.common.core.exception.CheckedException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;

/**
 * @author: yangpengwei
 * @time: 2020/12/1 10:50 上午
 * @description index (聊天信息) 接口的请求参数
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "会话存档-聊天信息")
public class ReqMsgIndexDTO {


    @ApiModelProperty(value = "检索对象id")
    private Integer userId;

    @ApiModelProperty(value = "检索对象名称")
    private String userName;

    @ApiModelProperty(value = "聊天对象名称")
    private String toUserName;

    @Range(min = 0, max = 2, message = "聊天对象类型无效")
    @ApiModelProperty(value = "检索对象类型")
    private Integer UserType;


    @Range(min = 0, max = 2, message = "聊天对象类型无效")
    @ApiModelProperty(value = "聊天对象类型")
    private Integer toUserType;


    @ApiModelProperty(value = "聊天对象Id")
    private Integer toUserId;

    @NotNull(message = "聊天内容类型无效")
    @ApiModelProperty(value = "聊天内容类型，可选参数")
    private Integer type;

    @ApiModelProperty(value = "当前页")
    private Integer current;

    @ApiModelProperty(value = "分页大小")
    private Integer size;

    @ApiModelProperty(value = "信息内容")
    private String content;

    @ApiModelProperty(value = "开始时间")
    private String dateTimeStart;

    @ApiModelProperty(value = "结束时间")
    private String dateTimeEnd;


    public Integer getType() {
        type = null == type ? 0 : type;
       // boolean b = type < 0 || (type > 7 && type < 100) || type > 100;
        boolean b = type < 0 || (type > 14 && type < 100) || type > 100;
        if (b) {
            throw new CheckedException("聊天内容类型无效");
        }
        return type;
    }

    public String getContent() {
        content = null == content ? "" : content;
        return content;
    }

//    public String getDateTimeStart() {
//        if (null != dateTimeStart && !dateTimeStart.isEmpty()) {
//            return "" + DateUtils.getMillsByS1(dateTimeStart);
//        }
//        return null;
//    }
//
//    public String getDateTimeEnd() {
//        if (null != dateTimeEnd && !dateTimeEnd.isEmpty()) {
//            return "" + DateUtils.getMillsByS1(dateTimeEnd);
//        }
//        return null;
//    }

}



